<?php

namespace StarCloud\Library;
use Framework\DiServices\HttpClient;
use Phalcon\Di;
use function GuzzleHttp\Psr7\build_query;

class SmsBao
{

    public static $account ="zunlong";
    public static $pwd = "9d165bc3e9cc47cab1f5bb9da83810b1";
    public static $url = "https://api.smsbao.com/sms?";

    public static function sendSms($mobile, $content)
    {
        /* @var $httpClient HttpClient */;
        $httpClient = Di::getDefault()->get('httpClient');

        $url = self::$url . http_build_query([
                'm' => $mobile,
                'c' => $content,
                'u' => self::$account,
                'p' => self::$pwd
            ]);
        $response = $httpClient->sendPostRequest($url);

        return $response->getBody()->getContents();
    }
}
